exports.search_organization_activity_all = function(req,res) {

    //获取restful参数
    var restfulParams = req.routeInfo.restfulParams;

    //最终结果
    var resultData = {};

    var skip = restfulParams.skip == undefined ? 0 : restfulParams.skip;

    var limit = restfulParams.limit == undefined ? config.publicConfig.LIMIT : restfulParams.limit;


    //任务流创建
    async.waterfall([

        function(cb){

            R.SEND_HTTP(
                req,
                {
                    url    : CORE_APIConfig.coreAPI.searchOrganizationActivity + "/oa_oid/" + restfulParams.oa_oid +"/skip/"+skip+"/limit/"+limit+"/sort_order/oa_create_time-desc" ,
//                  url    : CORE_APIConfig.coreAPI.searchOrganizationActivity + "/oa_oid/" + restfulParams.oa_oid +"/between/oa_type-7/skip/"+skip+"/limit/"+limit+"/sort_order/oa_create_time-desc" ,
                    method : 'POST'
                },
                function (err, data) {

                    resultData.activityList = data.data;

                    cb();
                }
            );
        },

        function(cb){

            var tasks = [];

            resultData.activityList.forEach(function (item, i) {

                //创建每一个插入任务
                tasks.push(function (cb) {

                    //如果为拼团，查询属于什么拼团
                    if(item.oa_type == 0){

                        R.SEND_HTTP(
                            req,
                            {
                                url: CORE_APIConfig.coreAPI.searchBulkPurchaseActivityConfig+"/bpac_oaid/"+item.oa_id,
                                method:'POST',
                                data : {
                                    fields:["bpac_type"].join(",")
                                }
                                
                            },
                            function (err, data) {

                                console.log(data);
                            	
                            	if (data.data.length == 0) {
                            		
                            		item.bpac_type = 0;
        							
                            	}else{
                                    item.bpac_type = data.data[0].bpac_type;
                                }

                                

                                cb();
                            }
                        );

                    }else{

                        cb();
                    }


                });

            });

            async.waterfall(tasks, cb);

        }
    ],function(err, result){

        //返回最终拼接结果
        RES.response(res,true,resultData);

    });

}
